Ext.define('MyDesktop.Programacion', {
    extend: 'Ext.ux.desktop.Module',

    //    requires: [
    //        'Ext.form.field.HtmlEditor'
    //        //'Ext.form.field.TextArea'
    //    ],

    id: 'programacion',

    init: function() {
        this.launcher = {
            text: 'Programacion Actividades',
            iconCls: 'notepad',
            handler: this.createWindow,
            scope: this
        }
    },

    createWindow: function() {
        var desktop = this.app.getDesktop();
        var win = desktop.getWindow('programacion');
        var ancho = Escritorio.Funciones.Ancho({
            desktop: desktop
        });
        var alto = Escritorio.Funciones.Alto({
            desktop: desktop
        });
        if (!win) {
            //var smc = new SistIntegral.QuejasReclamos();
            win = desktop.createWindow({
                id: 'programacion',
                title: 'PROGRAMACION ACTIVIDADES',
                minWidth: ancho,
                minHeight: alto,
                iconCls: 'notepad',
                animCollapse: false,
                border: false,
                //hideMode: 'offsets',
                //resizable: true,
                layout: 'border',

                html: '<div id="calendar-ct">'
                        + '<div style="display:none;">'
                            + '<div id="app-header-content">'
                                + '<div id="app-logo">'
                                    + '<div class="logo-top">&nbsp;</div>'
                                    + '<div id="logo-body">&nbsp;</div>'
                                    + '<div class="logo-bottom">&nbsp;</div>'
                                + '</div>'
                                + '<h1>' + titulogeneral + '</h1>'
                                + '<span id="app-msg" class="x-hidden">----</span>'
                            + '</div>'
                        + '</div>'
                    + '</div>',
                listeners: {
                    'resize': {
                        fn: function(thisa, width, height, oldWidth, oldHeight, eOpts ) {
                            if(Ext.getCmp('Calendario')){
                                //console.log("hola");
                                Ext.getCmp('Calendario').setWidth(this.getWidth()-10);
                                Ext.getCmp('Calendario').setHeight(this.getHeight() - 30);
                            }
                                
                            
                        }
                    }
                }
                //items: [smc.Inicio()]
            });
        } else {
            win.setWidth(ancho);
            win.setHeight(alto);
        }
        win.show();

        win.on('show', function(obj, obj1) {
            new MyDesktop.Programacion.Calendario().Inicio();
        });

        win.on('beforeclose', function(obj, obj1) {
            Ext.getCmp('Calendario').destroy();
        });

        return win;
    }
});

Ext.define('MyDesktop.Programacion.Calendario', {
    Inicio: function() {
        Ext.Loader.setConfig({
            enabled: true,
            paths: {
                'Ext.calendar': 'Scripts/extjs/Integral/calendar/src'
            }
        });
        Ext.require([
            //'Ext.diag.layout.Context',
            //'Ext.diag.layout.ContextItem',
            'Ext.calendar.App'
        ]);
        Ext.onReady(function() {
            // launch the app:
            Ext.create('Ext.calendar.App');

            // update the header logo date:
            document.getElementById('logo-body').innerHTML = new Date().getDate();
        });
    }
});